//
//  SetSignController.m
//  reader
//
//  Created by THX on 2021/12/13.
//  Copyright © 2021 mo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "SetSignController.h"
#import "InfoViewController.h"

@interface SetSignController()
@property (nonatomic, strong) UITextField* input;
@property (nonatomic, strong) UIButton* btn;

@end

@implementation SetSignController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"更改签名";
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"grayBack"]];
    
    [self input];
    [self btn];
}


-(void)handleTouch:(UIButton *)button{
    [self.delegate setSign:[self input].text];
}

-(UITextField*)input{
    if(_input == nil){
        _input = [[UITextField alloc]initWithFrame:CGRectMake(self.view.frame.size.width/2-100, self.view.frame.size.height/3, 200, 40)];
        _input.backgroundColor = [UIColor whiteColor];
        _input.placeholder = @"输入新的签名";
        _input.text = _userSign;
        [self.view addSubview:_input];
    }
    return _input;
}

-(UIButton*)btn{
    //按钮背景颜色
    UIColor *backColor = [UIColor colorWithRed:0/255.0 green:201/255.0 blue:87/255.0 alpha:1.0];
    
    if (_btn == nil) {
        _btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        _btn.titleLabel.font = [UIFont systemFontOfSize:15];
        _btn.layer.cornerRadius = 10;
        [_btn setTitle:@"保存" forState:UIControlStateNormal];
        [_btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_btn setBackgroundColor:backColor];
        [_btn setFrame:CGRectMake(self.view.frame.size.width/2-35, self.view.frame.size.height/3+100, 70, 30)];
        [_btn addTarget:self action:@selector(handleTouch:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:_btn];
    }
    return _btn;
}



@end

